#!/usr/bin/env bash

. `dirname "$0"`/Tools/platform.sh

if test -f "Tools/khamake/khamake.js"; then
git -C `dirname "$0"` submodule update --remote --merge Tools/khamake
else
git -C `dirname "$0"` submodule update --init --remote Tools/khamake
git -C `dirname "$0"`/Tools/khamake checkout main
fi

if test -f "Backends/Kinc-hxcpp/khacpp/LICENSE.txt"; then
git -C `dirname "$0"` submodule update --remote --merge Backends/Kinc-hxcpp/khacpp
else
git -C `dirname "$0"` submodule update --init --remote Backends/Kinc-hxcpp/khacpp
git -C `dirname "$0"`/Backends/Kinc-hxcpp/khacpp checkout main
fi

if test -f "Tools/$KINC_PLATFORM/LICENSE.txt"; then
git -C `dirname "$0"` submodule update --remote --merge "Tools/$KINC_PLATFORM"
else
git -C `dirname "$0"` submodule update --init --remote "Tools/$KINC_PLATFORM"
git -C `dirname "$0"`/Tools/$KINC_PLATFORM checkout main
fi

if test -f "Kinc/get_dlc_dangerously"; then
git -C `dirname "$0"` submodule update --remote --merge Kinc
else
git -C `dirname "$0"` submodule update --init --remote Kinc
git -C `dirname "$0"`/Kinc checkout main
fi

bash `dirname "$0"`/Kinc/get_dlc_dangerously
